# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: rubicon <rubicon@mailo.com>
pkgname=irssi-tcl
pkgver=0_git20210919
_gitrev=9cd796620be88f0a1320d24532e35015a6dd94b5
pkgrel=0
pkgdesc="Tcl scripting module for the irssi IRC client"
url="https://github.com/horgh/irssi-tcl"
arch="all"
license="GPL-3.0-or-later"
depends="irssi"
makedepends="glib-dev irssi-dev tcl-dev"
subpackages="$pkgname-doc"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/horgh/irssi-tcl/archive/$_gitrev/irssi-tcl-$_gitrev.tar.gz
	global-scripts-path.patch
	irssi_dir-returns-home.patch
	"
builddir="$srcdir/irssi-tcl-$_gitrev"

build() {
	# complains about 'GTimeVal' being deprecated in the files
	# server-rec.h and irc-servers.h from the irssi-dev package
	sed -i 's/-Werror //' src/Makefile
	# using DEBUG has only 1 effect: allowing us to specify the
	# global irssi script directory (/usr/share/irssi/scripts)
	make TCL_DIR=/usr/include DEBUG=-DDEBUG -C src
}

package() {
	install -Dv src/libtcl.so \
		-t "$pkgdir"/usr/lib/irssi/modules/
	install -Dvm644 README.md COPYING docs/*script*.md \
		-t "$pkgdir"/usr/share/doc/"$pkgname"/
	install -Dvm644 tcl/* \
		-t "$pkgdir"/usr/share/irssi/scripts/tcl/
}

sha512sums="
5f659250a97310c49d4996f3067e92970e30b9689997277c01ad6869d42c1c90e3c5355ea2d83ad605c45583790a0073f1fb230d7bdf768ecfd319f1aff847e3  irssi-tcl-0_git20210919.tar.gz
86868af9d42cc1bb4423e59c47b154be46ac972e395686399cc682f278657c3842fabadaf58c897db44273bd4eb4499cd0cc0e54c591259a8469d1fec67ce087  global-scripts-path.patch
684854e7139dc18ea75d7ddeb1802eac82350854dd41d2c18fe4d543e4822016cc170a1673b032ad55881c75a0f5c4f99ee33a4b61ae41f90f1778ef8a65315a  irssi_dir-returns-home.patch
"
